package com.football;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

// Crea la llista de tricks
public class TopicsListActivity extends ListActivity {

	// label KEYS used to transfer parameters between activities
	public static final String LIST_SELECTION = "list_selection";
	public static final String XML_ARRAY = "xml_array";

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // Get values between activities
        Bundle extras = getIntent().getExtras();
        ArrayList<String> aFootballTopicNames = extras.getStringArrayList(XML_ARRAY);
        
        setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, aFootballTopicNames));

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);

        lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view,
              int position, long id) {
        	    Intent intent = new Intent();
        	    intent.putExtra(LIST_SELECTION, ((TextView) view).getText());
        	    intent.setClass(TopicsListActivity.this, VideoSelectorActivity.class);
        	  	startActivity(intent);
          }
        });       
    }
}
